package com.qvtu.web.config;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;



public class MyBatisPlusCodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/sx", "root", "root")
// 全局配置    保存路径 D://java//Web
                .globalConfig((scanner, builder) -> builder.author(scanner.apply("请输入作者名称？")).fileOverride().outputDir("D://java//Web"))
// 包配置
                .packageConfig((scanner, builder) -> builder.parent(scanner.apply("请输入包名？"))).packageConfig(builder -> builder.entity("domain"))
// 策略配置
                .strategyConfig((scanner, builder) -> builder.addInclude(getTables(scanner.apply("请输入表名，多 个英文逗号分隔？所有输入 all")))
                        .addTablePrefix("")
                        .controllerBuilder()
                        .enableRestStyle()
                        .enableHyphenStyle()
                        .entityBuilder()
                        .enableLombok()
                        .mapperBuilder().enableMapperAnnotation()
                        .build()).execute();
    }

    protected static List<String> getTables(String tables) {
        return "all" .equals(tables) ? Collections.emptyList() :
                Arrays.asList(tables.split(","));
    }
}
    // 处理 all 情况

